package com.bm.controller;

import com.bm.pojo.requestMsg.RequestLoginMsg;
import com.bm.pojo.user.User;
import com.bm.server.UserServer;
import com.google.gson.Gson;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * User: sx
 * Date: 2022/1/26
 * Time: 17:14
 * Description: java
 */
@RestController
public class UserController {
    @Resource
    private UserServer userServer;


    //@PostMapping("/login")
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    @CrossOrigin
    public String LoginUI(@RequestBody User user){
        RequestLoginMsg flag = userServer.loginUI(user.getAccount(),user.getPassord());
        //String json = JSON.toJSONString(flag);
        Gson gson = new Gson();
        String json = gson.toJson(flag);

        return json;
    }

    @RequestMapping(value = "/sign",method = RequestMethod.POST)
    @ResponseBody
    @CrossOrigin
    public String SignIu(@RequestBody User user){
       RequestLoginMsg flag = userServer.signUI(user);
        Gson gson = new Gson();
        String s = gson.toJson(flag.getMsg());
        return  s;
    }



}
